package com.fz.us.oa.web.controller.main.company;

import com.fz.us.admin.base.bean.Result;
import com.fz.us.admin.company.dto.CompanyDto;
import com.fz.us.admin.company.entity.Company;
import com.fz.us.admin.company.entity.User;
import com.fz.us.admin.company.service.CompanyService;
import com.fz.us.oa.web.controller.BaseController;
import com.fz.us.oa.web.shiro.bind.annotation.CurrentUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * 控制器 - 企业信息
 * ============================================================================
 * 版权所有 2016 。
 *
 * @author fallenpanda
 * @version 1.0 2016-08-03 。
 * ============================================================================
 */
@Controller
@RequestMapping(value = "/main/company")
public class CompanyController extends BaseController {

    private static final long serialVersionUID = 8590615741679949857L;

    @Autowired
    private CompanyService companyService;

    @RequestMapping(value = "read", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
    public Object read(@CurrentUser User user) {
        Company company = user.getCompany();

        CompanyDto companyDto = companyService.entityToDto(company);

        Result result = resultService.success("", companyDto);

        return ajaxJson(result);
    }

}
